import request from '@/utils/request'

export function getList(params) {
  return request({
    url: '/get',
    method: 'get',
    params
  })
}
// 上传一个新的article
export function uploadArticle(params) {
  console.log('=======================================>')
  console.log(params)
  return request({
    url: '/articles',
    method: 'post',
    data: {
      title: params.title,
      content: params.content,
      category: params.category,
      tags: params.tags.join(),
      tabloid: params.tabloid,
      type: params.type === '原创' ? 1 : 0,
      author: params.author,
      reprintURL: params.reprintURL,
      status: params.status,
      coverImg: params.coverImg
    }
  })
}
export function deleteArticle(id) {
  return request({
    url: '/article/' + id,
    method: 'delete'
  })
}
export function updateArticle(params) {
  console.log('=======================================>')
  console.log(params)
  return request({
    url: '/article/' + params.id,
    method: 'put',
    data: {
      title: params.title,
      content: params.content,
      category: params.category,
      tags: params.tags.join(),
      tabloid: params.tabloid,
      type: params.type === '原创' ? 1 : 0,
      author: params.author,
      reprintURL: params.reprintURL,
      status: params.status,
      coverImg: params.coverImg
    }
  })
}
export function openMdFIleLocal(id) {
  return request({
    url: '/openFile?articleId=' + id,
    method: 'get'
  })
}
